﻿using EfInfra;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace EfLearn.Uniter
{
    internal class Ddler
    {
        public static void DeleteDb()
        {
            var db = DI.InsProvider.GetService<MyContext>();
            db!.Database.EnsureDeleted();  
            
        }

        public static void CreateDb()
        {
            var db = DI.InsProvider.GetService<MyContext>();
            db!.Database.EnsureCreated();
        }

        public static void GenerateScripts()
        {
            var db = DI.InsProvider.GetService<MyContext>();
            string str=db!.Database.GenerateCreateScript();
            Console.WriteLine(str);
        }
    }
}